#include<stdio.h>
#include<string.h>
#include<windows.h>
//3.编写代码，演示多个字符从两端移动，向中间汇聚
int main()
{
	char arr1[] = "I LOVE U three thousand times Renshuang";
	char arr2[] = "#######################################";
	int left = 0;
	int right = strlen(arr1)-1;
	while (left <= right)
	{
		arr2[left] = arr1[left];
		arr2[right] = arr1[right];
		printf("%s\n", arr2);
		Sleep(1000);//休眠1秒
		system("cls");//清空屏幕
		left++;
		right--;
	}
	printf("%s\n", arr2);
	return 0;
}

//4.模拟用户登录场景，并且只能登录三次
//(只允许输入三次密码，如果密码正确则提示登录成功，如果三次均输入错误，则退出程序)
int main()
{
	int i = 0;
	//假设正确的密码是字符串"123456"
	char password[20] = { 0 };
	for (i = 0; i < 3; i++)
	{
		printf("请输入密码:>");
		scanf("%s", password);//数组不用&
		//if(password == "123456") //err - 两个字符串比较，不能使用==，应该用strcmp
		if (strcmp(password, "123456") == 0)//比ASCII码值，abc d ef>abc c qqqq
		{
			printf("登录成功\n");
			break;
		}
		else
		{
			printf("密码错误，请重新输入\n");
		}
	}
	if (i == 3)
	{
		printf("三次均输入错误，退出程序\n");
	}
	return 0;
}